<template>
  <div>
    <p :class="{ a: bool }">动态类名</p>
    <button @click="Fn">设置</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      bool: true,
    };
  },
  methods: {
    Fn() {
      this.bool = !this.bool;
    },
  },
};
</script>

<style>
.a {
  color: red;
}
</style>
